package alp.starcode.nudtportal.framework.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @program: nudt-portal
 * @description: redis操作用户相关工具类
 * @author: cy
 * @create: 2024-04-07 13:13
 **/
@Component
public class RedisUserUtil {

    @Autowired
    RedisUtils redisUtils;

    /**
     * 删除用户
     *
     * @param userKey
     */
    public  void deleteUser(String userKey){
        redisUtils.delete(userKey);
    }

    public  Boolean hasUserKey(String key) {
        return redisUtils.hasKey(key);
    }

    /**
     * 设置指定 key 的值
     *
     * @param key
     * @param value
     */
    public  void set(String key, String value) {
        redisUtils.setEx(key, value,30, TimeUnit.MINUTES);
    }

    /**
     * 获取指定 key 的值
     *
     * @param key
     * @return
     */
    public  String get(String key) {
        return redisUtils.get(key);
    }
}
